package homework_07.homework_Car;

public class AutomoblieRent {
    public Automoblie[] Automoblies=new Automoblie[8];
    public void carInIt(){
        Automoblies[0] =new Car("宝马",800,"x6");
        Automoblies[1] =new Car("宝马",600,"x5");
        Automoblies[2] =new Car("别克",400,"GL8");
        Automoblies[3] =new Car("别克",300,"君威");
        Automoblies[4] =new Bus("金龙",600,"15坐以下");
        Automoblies[5] =new Bus("金杯",700,"15坐以下");
        Automoblies[6] =new Bus("金龙",1500,"15坐以上");
        Automoblies[7] =new Bus("金杯",1600,"15坐以上");
    }
    public Automoblie zuChe(String brand,String type,String seatCount){
        Automoblie Che=null;
        for(int i=0;i<Automoblies.length;i++){
            if (Automoblies[i] instanceof Car){
                Car car =(Car) Automoblies[i];
                if(car.getBrand().equals(brand)&&car.getType().equals(type)){
                    Che = car;
                    break;
                }
            }else {
                Bus bus = (Bus)Automoblies[i];
                if (bus.getBrand().equals(brand)&&bus.getSeatCount().equals(seatCount)){
                    Che = bus;
                    break;
                }
            }
        }
        return Che;
    }

}
